//
//  GiftTableViewCell.m
//  HuaRun2
//
//  Created by admin on 17/8/29.
//  Copyright © 2017年 Sunny. All rights reserved.
//

#import "GiftTableViewCell.h"
#import "ImageLabView.h"
#import "GiftModel.h"

@interface GiftTableViewCell ()

@property (nonatomic, strong) UIView * backView;

//序号
@property (nonatomic, strong) UILabel * numLab;
//电话
@property (nonatomic, strong) ImageLabView * noteView;
//
@property (nonatomic, strong) ImageLabView * contactView;
//会议
@property (nonatomic, strong) ImageLabView * meetingView;
//礼物
@property (nonatomic, strong) ImageLabView * giftView;

@end

@implementation GiftTableViewCell

#pragma mark - life cycle
- (void)dealloc {
    NSLog(@"%@ dealloc", [self class]);
}

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];
    
    // Configure the view for the selected state
}

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.selectionStyle = UITableViewCellSelectionStyleNone;

        self.contentView.backgroundColor = RGBA(249, 249, 249, 1);
        [self viewInit];
        [self layoutInit];
    }
    return self;
}

- (void)viewInit {
    [self.contentView addSubview:self.backView];
    [self.contentView addSubview:self.numLab];

    [self.contentView addSubview:self.noteView];
    [self.contentView addSubview:self.contactView];
    [self.contentView addSubview:self.meetingView];
    [self.contentView addSubview:self.giftView];
//    
//    _numLab.text = @"GIF-6301";
    
}

- (void)layoutInit {
    
    weakself(ws);
    
    [self.backView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(ws.contentView).offset(kMargin10);
        make.right.mas_equalTo(ws.contentView).offset(-kMargin10);
        make.top.mas_equalTo(ws.contentView).offset(kMargin10);
        make.bottom.mas_equalTo(ws.contentView);
    }];
    
    [self.numLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(ws.backView).offset(kMargin15);
        make.top.mas_equalTo(ws.backView).offset(kMargin10/2);
        make.right.mas_equalTo(ws.backView).offset(-kMargin15);
        make.height.mas_equalTo(15);
    }];

    [self.noteView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(ws.numLab).offset(kMargin10);
        make.top.mas_equalTo(ws.numLab.mas_bottom).offset(kMargin10/2);
//        make.right.mas_equalTo(ws.contentView).offset(-kMargin10);
    }];
    
    [self.contactView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(ws.noteView.mas_bottom).offset(kMargin10/2);
        make.left.mas_equalTo(ws.noteView).offset(0);
    }];
    
    [self.meetingView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(ws.contactView.mas_bottom).offset(kMargin10/2);
        make.left.mas_equalTo(ws.noteView).offset(0);
    }];
    
    [self.giftView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(ws.meetingView.mas_bottom).offset(kMargin10/ 2);
        make.left.mas_equalTo(ws.noteView).offset(0);
    }];

}
#pragma mark - getter setter 
- (void)setGiftModel:(GiftModel *)giftModel {
    _giftModel = giftModel;
    _noteView.infoStr =     [NSString showSpaceStringWithStr:giftModel.giftCategory];
    _contactView.infoStr =  [NSString showSpaceStringWithStr:giftModel.name];
    _meetingView.infoStr =  [NSString showSpaceStringWithStr:giftModel.givingDate];
    _giftView.infoStr =     [NSString showSpaceStringWithStr:giftModel.remarks];

}

- (UILabel *)numLab {
    if (!_numLab) {
        self.numLab = [UILabel new];
        _numLab.textAlignment = NSTextAlignmentLeft;
        _numLab.font = kFontSize15;
        _numLab.textColor = [UIColor colorWithHex:@"3c3c3c"];
    }
    return _numLab;
}

- (ImageLabView *)noteView {
    if (!_noteView) {
        self.noteView = [ImageLabView new];
        _noteView.iconView.image = [UIImage imageNamed:@"类型"];
        _noteView.infoStr = @"备注";
    }
    return _noteView;
}

- (ImageLabView *)contactView {
    if (!_contactView) {
        self.contactView = [ImageLabView new];
        //        _contactView.imageSize = CGSizeMake(25, 25);
        _contactView.iconView.image = [UIImage imageNamed:@"礼物"];
        _contactView.infoStr = @"联系人";
        
    }
    return _contactView;
}

- (ImageLabView *)meetingView {
    if (!_meetingView) {
        self.meetingView = [ImageLabView new];
        //        _meetingView.imageSize = CGSizeMake(25, 25);
        _meetingView.iconView.image = [UIImage imageNamed:@"时间_1"];
        _meetingView.infoStr = @"会议";
        
    }
    return _meetingView;
}

- (ImageLabView *)giftView {
    if (!_giftView) {
        self.giftView = [ImageLabView new];
        //        _giftView.imageSize = CGSizeMake(25, 25);
        _giftView.iconView.image = [UIImage imageNamed:@"备注"];
        _giftView.infoStr = @"礼物";
        
    }
    return _giftView;
}

- (UIView *)backView {
    if (!_backView) {
        self.backView = [UIView new];
        _backView.backgroundColor = [UIColor whiteColor];
    }
    return _backView;
}
@end
